home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / applic / ntp / depredated / ntp.3.4 / patches / patch6.Z / patch6
Encoding:
Text File  |  1991-09-29  |  15.1 KB  |  569 lines

  1. System: ntp version 3.4
  2. Patch #: 6
  3. Priority: 
  4.  
  5. Add bit in flags which allow a peer to be synced to.  Changed a char to a bit
  6. field so that it is always signed.
  7. There is now a run-time option that can be specified in the configuration 
  8. which specifies if we will synchronize to unconfigured hosts.  Fixes to
  9. receive() logic state machine.
  10. Add support for "trusting" directive in NTP configuration file.  It allows 
  11. you to specify at run time if non-configured peers will be synced to.
  12. More fixes.  Make sure that compliance is not negative.
  13. Bug fix for VAX_COMPILER_FLT_BUG test, start of test for Sun problem.
  14.  
  15. From:
  16.  
  17. Description:
  18.  
  19. Repeat-By:
  20.  
  21. Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your ntp source
  22.     directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
  23.     If you don't have the patch program, apply the following by hand,
  24.     or get patch (version 2.0, latest patchlevel).
  25.  
  26.     After patching:
  27.         make depend
  28.         make
  29.         make install
  30.  
  31.     If patch indicates that patchlevel is the wrong version, you may need
  32.     to apply one or more previous patches, or the patch may already
  33.     have been applied.  See the patchlevel.h file to find out what has or
  34.     has not been applied.  In any event, don't continue with the patch.
  35.  
  36.     If you are missing previous patches they can be obtained from me:
  37.  
  38.     Louis A. Mamakos
  39.     louie@trantor.umd.edu
  40.  
  41.     You can also get the patches via anonymous FTP from
  42.     trantor.umd.edu.
  43.  
  44. Index: patchlevel.h
  45. Prereq: 5
  46. 1c1
  47. < #define PATCHLEVEL 5
  48. ---
  49. > #define PATCHLEVEL 6
  50.  
  51. Index: ntp.h
  52. *** ntp.h.old    Fri Mar 31 16:39:24 1989
  53. --- ntp.h    Fri Mar 31 16:39:25 1989
  54. ***************
  55. *** 1,7 ****
  56. ! /* $Source: /usr/users/louie/ntp/RCS/ntp.h,v $ $Revision: 3.4.1.3 $ $Date: 89/03/29 12:26:18 $ */
  57.   
  58.   /*
  59.    *  $Log:    ntp.h,v $
  60.    * Revision 3.4.1.3  89/03/29  12:26:18  louie
  61.    * Removed some unused #defines.  Replaced MAXSTRATUM with NTP_INFIN per new
  62.    * spec.  The variable 'mode' in the peer structure has been renamed 'hmode'
  63. --- 1,11 ----
  64. ! /* $Source: /usr/users/louie/ntp/RCS/ntp.h,v $ $Revision: 3.4.1.4 $ $Date: 89/03/31 16:34:50 $ */
  65.   
  66.   /*
  67.    *  $Log:    ntp.h,v $
  68. +  * Revision 3.4.1.4  89/03/31  16:34:50  louie
  69. +  * Add bit in flags which allow a peer to be synced to.  Changed a char to a bit
  70. +  * field so that it is always signed.
  71. +  * 
  72.    * Revision 3.4.1.3  89/03/29  12:26:18  louie
  73.    * Removed some unused #defines.  Replaced MAXSTRATUM with NTP_INFIN per new
  74.    * spec.  The variable 'mode' in the peer structure has been renamed 'hmode'
  75. ***************
  76. *** 264,273 ****
  77.   #define    INFO_QUERY    62    /* **** THIS implementation dependent **** */
  78.   #define    INFO_REPLY    63    /* **** THIS implementation dependent **** */
  79.   
  80. - #define    ACTIVE        0x01    /* opposite of PASIVE */
  81. - #define MEDIAN        0x02
  82.   
  83.   /* =================  table 3.2 Peer Variables    ================= */
  84.   struct ntp_peer {
  85.       struct ntp_peer *next, *prev;
  86. --- 268,274 ----
  87. ***************
  88. *** 276,281 ****
  89. --- 277,283 ----
  90.       int    flags;            /* local flags */
  91.   #define    PEER_FL_CONFIG        1
  92.   #define    PEER_FL_AUTHENABLE    2
  93. + #define    PEER_FL_SYNC        0x1000    /* peer can bet sync'd to */
  94.   #define    PEER_FL_BCAST        0x2000    /* broadcast peer */
  95.   #define    PEER_FL_SELECTED    0x8000    /* actually used by query routine */
  96.   
  97. ***************
  98. *** 351,357 ****
  99.       u_char leap;
  100.       u_char stratum;
  101.       u_char ppoll;
  102. !     char precision;
  103.   
  104.       u_char hpoll;
  105.       u_char filler1;
  106. --- 353,359 ----
  107.       u_char leap;
  108.       u_char stratum;
  109.       u_char ppoll;
  110. !     int precision:8;
  111.   
  112.       u_char hpoll;
  113.       u_char filler1;
  114.  
  115. Index: ntp_proto.c
  116. *** ntp_proto.c.old    Fri Mar 31 16:39:33 1989
  117. --- ntp_proto.c    Fri Mar 31 16:39:35 1989
  118. ***************
  119. *** 1,5 ****
  120.   #ifndef    lint
  121. ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp_proto.c,v $ $Revision: 3.4.1.4 $ $Date: 89/03/29 12:29:10 $";
  122.   #endif
  123.   
  124.   /*
  125. --- 1,5 ----
  126.   #ifndef    lint
  127. ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntp_proto.c,v $ $Revision: 3.4.1.5 $ $Date: 89/03/31 16:36:38 $";
  128.   #endif
  129.   
  130.   /*
  131. ***************
  132. *** 10,15 ****
  133. --- 10,20 ----
  134.    *
  135.    *
  136.    * $Log:    ntp_proto.c,v $
  137. +  * Revision 3.4.1.5  89/03/31  16:36:38  louie
  138. +  * There is now a run-time option that can be specified in the configuration 
  139. +  * which specifies if we will synchronize to unconfigured hosts.  Fixes to
  140. +  * receive() logic state machine.
  141. +  * 
  142.    * Revision 3.4.1.4  89/03/29  12:29:10  louie
  143.    * The variable 'mode' in the peer structure was renamed 'hmode'.  Add 
  144.    * poll_update() calls in a few places per Mills.  The receive() procedure is
  145. ***************
  146. *** 105,110 ****
  147. --- 110,116 ----
  148.   extern int debug;
  149.   extern void dump_pkt();
  150.   #endif
  151. + extern int trusting;
  152.   extern struct sysdata sys;
  153.   extern struct list peer_list;
  154.   extern struct ntp_peer *check_peer();
  155. ***************
  156. *** 316,321 ****
  157. --- 322,340 ----
  158.                          this from */
  159.           peer->hmode = MODE_SYM_PAS;
  160.           clear(peer);
  161. + #if    1
  162. +         /*
  163. +          *  If we decide to consider any random NTP peer that might
  164. +          *  come as a peer we might sync to, then set the PEER_FL_SYNC
  165. +          *  flag in the peer structure.
  166. +          *
  167. +          *  Alternatively, we could change the hmode to MODE_SERVER, 
  168. +          *  but then the peer state wouldn't be persistant.
  169. +          */
  170. +         if (trusting)
  171. +             peer->flags |= PEER_FL_SYNC;
  172. + #endif
  173.           enqueue(&peer_list, peer);
  174.       }
  175.   
  176. ***************
  177. *** 351,367 ****
  178.       }
  179.   #endif
  180.   
  181.   #ifdef    DEBUG
  182. !     if (peer_mode < MODE_SYM_ACT || peer_mode > MODE_BROADCAST ||
  183. !         peer->hmode < MODE_SYM_ACT || peer->hmode > MODE_BROADCAST) {
  184. !         printf("Bogus peer_mode or peer->hmode\n");
  185.           abort();
  186.       }
  187. - #endif
  188.   
  189.       switch (actions[peer_mode - 1][peer->hmode - 1]) {
  190.       case ACT_RECV:
  191. !         if (!(peer->flags & PEER_FL_CONFIG == 0 &&
  192.                 STRMCMP(pkt->stratum, >, sys.stratum))) {
  193.               peer->reach |= 1;
  194.               process_packet(dst, pkt, tvp, peer);
  195. --- 370,393 ----
  196.       }
  197.   #endif
  198.   
  199. +     if (peer_mode < MODE_SYM_ACT || peer_mode > MODE_BROADCAST) {
  200. +         syslog(LOG_DEBUG, "Bogus peer_mode %d from %s", peer_mode,
  201. +                ntoa(dst->sin_addr));
  202.   #ifdef    DEBUG
  203. !         if (debug > 3) abort();
  204. ! #endif
  205. !         return;
  206. !     }
  207. !     if (peer->hmode < MODE_SYM_ACT || peer->hmode > MODE_BROADCAST) {
  208. !         syslog(LOG_ERR, "Bogus hmode %d for peer %s", peer->hmode,
  209. !                ntoa(peer->src.sin_addr));
  210.           abort();
  211.       }
  212.   
  213.       switch (actions[peer_mode - 1][peer->hmode - 1]) {
  214.       case ACT_RECV:
  215. !         if (!(((peer->flags & PEER_FL_CONFIG) == 0) &&
  216.                 STRMCMP(pkt->stratum, >, sys.stratum))) {
  217.               peer->reach |= 1;
  218.               process_packet(dst, pkt, tvp, peer);
  219. ***************
  220. *** 369,386 ****
  221.           }
  222.           /* Note fall-through */
  223.       case ACT_ERROR:
  224. !         if ((peer != &dummy_peer) && (peer->flags & PEER_FL_CONFIG))
  225. !             demobilize(peer);
  226. !         return;
  227.   
  228.       case ACT_PKT:
  229. !         if (!((peer->flags & PEER_FL_CONFIG == 0) &&
  230. !             STRMCMP(pkt->stratum, >, sys.stratum))) {
  231.               peer->reach |= 1;
  232.               process_packet(dst, pkt, tvp, peer);
  233.               break;
  234.           }
  235. !         /* note fall-through */
  236.       case ACT_XMIT:
  237.           process_packet(dst, pkt, tvp, peer);
  238.           poll_update(peer, peer->ppoll);
  239. --- 395,413 ----
  240.           }
  241.           /* Note fall-through */
  242.       case ACT_ERROR:
  243. !         if (((peer->flags & PEER_FL_CONFIG) == 0) &&
  244. !             (peer != &dummy_peer))
  245. !             demobilize(&peer_list, peer);
  246. !         break;
  247.   
  248.       case ACT_PKT:
  249. !         if (!(((peer->flags & PEER_FL_CONFIG) == 0) &&
  250. !               STRMCMP(pkt->stratum, >, sys.stratum))) {
  251.               peer->reach |= 1;
  252.               process_packet(dst, pkt, tvp, peer);
  253.               break;
  254.           }
  255. !         /* Note fall-through */
  256.       case ACT_XMIT:
  257.           process_packet(dst, pkt, tvp, peer);
  258.           poll_update(peer, peer->ppoll);
  259. ***************
  260. *** 989,995 ****
  261.                  inet_ntoa(peer->src.sin_addr), peer->stratum);
  262.   #endif
  263.       /* Sanity check 0. ?? */
  264. !     if (!(peer->flags & PEER_FL_CONFIG))
  265.           return(0);
  266.   
  267.       /* Sanity check 1. */
  268. --- 1016,1022 ----
  269.                  inet_ntoa(peer->src.sin_addr), peer->stratum);
  270.   #endif
  271.       /* Sanity check 0. ?? */
  272. !     if (!(peer->flags & PEER_FL_SYNC))
  273.           return(0);
  274.   
  275.       /* Sanity check 1. */
  276. ***************
  277. *** 1020,1026 ****
  278.           The peer clock must be synchronized... and the interval since
  279.           the peer clock was last updated satisfy
  280.   
  281. !         peer.org - peer.reftime < NTP.MAXAGS
  282.        */
  283.       if (peer->leap == ALARM ||
  284.           (ul_fixed_to_double(&peer->org)
  285. --- 1047,1053 ----
  286.           The peer clock must be synchronized... and the interval since
  287.           the peer clock was last updated satisfy
  288.   
  289. !         peer.org - peer.reftime < NTP.MAXAGE
  290.        */
  291.       if (peer->leap == ALARM ||
  292.           (ul_fixed_to_double(&peer->org)
  293.  
  294. Index: ntpd.c
  295. *** ntpd.c.old    Fri Mar 31 16:39:44 1989
  296. --- ntpd.c    Fri Mar 31 16:39:46 1989
  297. ***************
  298. *** 1,9 ****
  299.   #ifndef    lint
  300. ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntpd.c,v $ $Revision: 3.4.1.4 $ $Date: 89/03/29 12:30:46 $";
  301.   #endif    lint
  302.   
  303.   /*
  304.    *  $Log:    ntpd.c,v $
  305.    * Revision 3.4.1.4  89/03/29  12:30:46  louie
  306.    * peer->mode has been renamed peer->hmode.  Drop PEER_FL_SYNC since the
  307.    * PEER_FL_CONFIG flag means much the same thing.
  308. --- 1,13 ----
  309.   #ifndef    lint
  310. ! static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntpd.c,v $ $Revision: 3.4.1.5 $ $Date: 89/03/31 16:37:49 $";
  311.   #endif    lint
  312.   
  313.   /*
  314.    *  $Log:    ntpd.c,v $
  315. +  * Revision 3.4.1.5  89/03/31  16:37:49  louie
  316. +  * Add support for "trusting" directive in NTP configuration file.  It allows 
  317. +  * you to specify at run time if non-configured peers will be synced to.
  318. +  * 
  319.    * Revision 3.4.1.4  89/03/29  12:30:46  louie
  320.    * peer->mode has been renamed peer->hmode.  Drop PEER_FL_SYNC since the
  321.    * PEER_FL_CONFIG flag means much the same thing.
  322. ***************
  323. *** 114,119 ****
  324. --- 118,124 ----
  325.   int doset = 1;
  326.   int ticked;
  327.   int selfds;
  328. + int trusting = 1;
  329.   
  330.   double WayTooBig = WAYTOOBIG;
  331.   unsigned long clock_watchdog;
  332. ***************
  333. *** 242,253 ****
  334.           setlogmask(LOG_UPTO(LOG_INFO));
  335.   #endif    /* LOG_DAEMON */
  336.   
  337. !     syslog(LOG_NOTICE, "%s version $Revision: 3.4.1.4 $", prog_name);
  338.       syslog(LOG_NOTICE, "patchlevel %d", PATCHLEVEL);
  339.   
  340.   #ifdef    DEBUG
  341.       if (debug)
  342. !         printf("%s version $Revision: 3.4.1.4 $ patchlevel %d\n",
  343.                  prog_name, PATCHLEVEL);
  344.   #endif
  345.       (void) setpriority(PRIO_PROCESS, 0, -10);
  346. --- 247,258 ----
  347.           setlogmask(LOG_UPTO(LOG_INFO));
  348.   #endif    /* LOG_DAEMON */
  349.   
  350. !     syslog(LOG_NOTICE, "%s version $Revision: 3.4.1.5 $", prog_name);
  351.       syslog(LOG_NOTICE, "patchlevel %d", PATCHLEVEL);
  352.   
  353.   #ifdef    DEBUG
  354.       if (debug)
  355. !         printf("%s version $Revision: 3.4.1.5 $ patchlevel %d\n",
  356.                  prog_name, PATCHLEVEL);
  357.   #endif
  358.       (void) setpriority(PRIO_PROCESS, 0, -10);
  359. ***************
  360. *** 692,697 ****
  361. --- 697,713 ----
  362.           if (strcmp(name, "maxpeers") == 0) {
  363.               if (fscanf(fp, "%d", &sys.maxpeers) != 1)
  364.                   error = TRUE;
  365. +         } else if (strcmp(name, "trusting") == 0) {
  366. +             if (fscanf(fp, "%s", name) != 1)
  367. +                 error = TRUE;
  368. +             else {
  369. +                 if (*name == 'Y' || *name == 'y') {
  370. +                     trusting = 1;
  371. +                 } else if (*name == 'N' || *name == 'n') {
  372. +                     trusting = 0;
  373. +                 } else
  374. +                     trusting = atoi(name);
  375. +             }
  376.           } else if (strcmp(name, "debuglevel") == 0) {
  377.               if (fscanf(fp, "%d", &debuglevel) != 1)
  378.                   error = TRUE;
  379. ***************
  380. *** 798,811 ****
  381. --- 814,830 ----
  382.                               peer->hmode = MODE_SYM_ACT;
  383.                               peer->stopwatch = stagger;
  384.                               stagger += (1<<CLOCK_ADJ);
  385. +                             peer->flags |= PEER_FL_SYNC;
  386.                               break;
  387.                           case MODE_CLIENT:    /* "server" */
  388.                               peer->hmode = MODE_CLIENT;
  389.                               peer->stopwatch = stagger;
  390.                               stagger += (1<<CLOCK_ADJ);
  391. +                             peer->flags |= PEER_FL_SYNC;
  392.                               break;
  393.                           case MODE_SYM_PAS:    /* "passive" */
  394.                               peer->hmode = MODE_SYM_PAS;
  395. +                             peer->flags |= PEER_FL_SYNC;
  396.                               break;
  397.                           default:
  398.                               printf("can't happen\n");
  399.  
  400. Index: stat.pl
  401. Prereq: 3.4.1.3
  402. *** stat.pl.old    Fri Mar 31 16:39:51 1989
  403. --- stat.pl    Fri Mar 31 16:39:52 1989
  404. ***************
  405. *** 1,5 ****
  406.   #!/usr/bin/perl  
  407. ! # $Source: /usr/users/louie/ntp/RCS/stat.pl,v $ $Revision: 3.4.1.3 $ $Date: 89/03/29 12:47:32 $
  408.   #
  409.   #  Make plots from ntpd syslog messages.  Invoked as:
  410.   #
  411. --- 1,5 ----
  412.   #!/usr/bin/perl  
  413. ! # $Source: /usr/users/louie/ntp/RCS/stat.pl,v $ $Revision: 3.4.1.4 $ $Date: 89/03/31 16:38:42 $
  414.   #
  415.   #  Make plots from ntpd syslog messages.  Invoked as:
  416.   #
  417. ***************
  418. *** 94,100 ****
  419.               $clk{$in[8]} = $clocks++;
  420.           }
  421.           $t = $t - $start;
  422. !         print CLK $t,$clk{$in[8]},"\n";
  423.   
  424.       }
  425.       if (/.* ntpd\[[0-9]*\]: adjust:/) {
  426. --- 94,100 ----
  427.               $clk{$in[8]} = $clocks++;
  428.           }
  429.           $t = $t - $start;
  430. !         print CLK $t," ",$clk{$in[8]},"\n";
  431.   
  432.       }
  433.       if (/.* ntpd\[[0-9]*\]: adjust:/) {
  434. ***************
  435. *** 123,128 ****
  436. --- 123,131 ----
  437.           #
  438.           #  Scale compliance by T (2**18)
  439.           #
  440. +         if ( $in[15] < 0 ) {
  441. +             $in[15] = -$in[15];
  442. +         }
  443.           print COMP $t," ",$in[15] * 2**18, "\n";
  444.       }
  445.   }
  446. ***************
  447. *** 132,138 ****
  448.   } else {
  449.       $last = int($t);
  450.   }
  451. ! print "$recs records spanning %t hours.\n";
  452.   
  453.   close OFF;
  454.   close DRIFT;
  455. --- 135,141 ----
  456.   } else {
  457.       $last = int($t);
  458.   }
  459. ! print "$recs records spanning $t hours.\n";
  460.   
  461.   close OFF;
  462.   close DRIFT;
  463. ***************
  464. *** 206,213 ****
  465.       unlink "stats.clk";
  466.   }
  467.   
  468. - ;# $Header: /usr/users/louie/ntp/RCS/stat.pl,v 3.4.1.3 89/03/29 12:47:32 louie Exp $
  469.   ;# Process single-character switches with switch clustering.  Pass one argument
  470.   ;# which is a string containing all switches that take an argument.  For each
  471.   ;# switch found, sets $opt_x (where x is the switch name) to the value of the
  472. --- 209,214 ----
  473.  
  474. Index: test.c
  475. *** test.c.old    Fri Mar 31 16:39:55 1989
  476. --- test.c    Fri Mar 31 16:39:55 1989
  477. ***************
  478. *** 1,9 ****
  479.   #ifndef    lint
  480. ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/test.c,v $ $Revision: 3.4.1.1 $ $Date: 89/03/22 18:32:26 $";
  481.   #endif
  482.   
  483.   /*
  484.    * $Log:    test.c,v $
  485.    * Revision 3.4.1.1  89/03/22  18:32:26  louie
  486.    * patch3: Use new RCS headers.
  487.    * 
  488. --- 1,12 ----
  489.   #ifndef    lint
  490. ! static char *RCSid = "$Source: /usr/users/louie/ntp/RCS/test.c,v $ $Revision: 3.4.1.2 $ $Date: 89/03/31 16:39:19 $";
  491.   #endif
  492.   
  493.   /*
  494.    * $Log:    test.c,v $
  495. +  * Revision 3.4.1.2  89/03/31  16:39:19  louie
  496. +  * Bug fix for VAX_COMPILER_FLT_BUG test, start of test for Sun problem.
  497. +  * 
  498.    * Revision 3.4.1.1  89/03/22  18:32:26  louie
  499.    * patch3: Use new RCS headers.
  500.    * 
  501. ***************
  502. *** 70,78 ****
  503. --- 73,85 ----
  504.               exit(2);
  505.           if (test3(1))
  506.               exit(3);
  507. +         if (test4(1))
  508. +             exit(4);
  509.       } else {
  510.           if (test3(0))
  511.               exit(3);
  512. +         if (test4(0))
  513. +             exit(4);
  514.       }
  515.       exit(0);
  516.   }
  517. ***************
  518. *** 124,134 ****
  519.   
  520.       dbl = ul;
  521.   #ifdef    VAX_COMPILER_FLT_BUG
  522. !     if (dbl < 0.0) a += 4.294967296e9;
  523.   #endif
  524.       if (dbl != 2147483648.0) {
  525. !         printf("test3 fails %lu != %f - can't convert from unsigned long to float\n",
  526. !                ul, dbl);
  527.           return 1;
  528.       } else {
  529.           if (v)
  530. --- 131,142 ----
  531.   
  532.       dbl = ul;
  533.   #ifdef    VAX_COMPILER_FLT_BUG
  534. !     if (dbl < 0.0) dbl += 4.294967296e9;
  535.   #endif
  536.       if (dbl != 2147483648.0) {
  537. !         printf("test3 fails: can't convert from unsigned long to float\n");
  538. !         printf("             (%lu != %f)\n", ul, dbl);
  539. !         printf("Try defining VAX_COMPILER_FLT_BUG in the Makefile.\n");
  540.           return 1;
  541.       } else {
  542.           if (v)
  543. ***************
  544. *** 137,140 ****
  545. --- 145,163 ----
  546.       }
  547.   }
  548.   
  549. + test4(v)
  550. +     int v;
  551. + {
  552. +     /* 
  553. +      * Need a test for the SUN 2^31 - 2^32 problem (in ntpsubs.c).  Anyone
  554. +      * with a Sun out there that can come up with one?
  555. +      *
  556. +      */
  557. +     if (0) {
  558. +         printf("test4 fails:\n");
  559. +         printf("Try defining SUN_FLT_BUG in the Makefile\n");
  560. +         return 1;
  561. +     }
  562. +     return 0;
  563. + }
  564.   
  565.